<template>
  <view class="content" id="new_detail">
		<view class="c">
			<view class="title">{{detail.title}}</view>
			<view class="time">{{detail.created_at}}</view>
			<rich-text :nodes="content"></rich-text>
		</view>
  </view>
</template>

<script>
import { GET_NEWS_DETAIL } from "@/api";
import { formatRichText } from "@/common/util"
export default {
  name: "NewsDetail",
  data() {
    return {
      storeId: this.$store.state.storeConf.store_id,
      tableId: this.$store.state.storeConf.table_id,
      deviceNum: this.$store.state.storeConf.device_num,
			content: '',
			detail:''
    };
  },
  onLoad(options) {
		var news_id = options.id ? options.id : 0, t = this
		if (!news_id) {
			t.$common.modelShow('温馨提示', '您的文章走丢了！', function(t) {
			  uni.navigateBack({
			  	animationType: 'slide-in-left',
			  	animationDuration: 500
			  });
			}, false);
		}
		
		this.getNewsDetail(news_id)
  },
  methods: {
		getNewsDetail(id) {
			var t = this, para = {
				store_id: this.storeId,
				table_id: this.tableId,
				news_id:  id,
			}
			
			t.$_get(GET_NEWS_DETAIL, para).then((res) => {
				if (res.code != 1) {
					t.$common.modelShow('温馨提示', res.msg, function(t) {
					  uni.navigateBack({
					  	animationType: 'slide-out-left',
					  	animationDuration: 500,
							complete: function(res) {
								console.log(res)
							}
					  });
					}, false);
					return
				}
				t.detail = res.data
				t.content = formatRichText(res.data.content)
			})
		}
  }
};
</script>

<style scoped>
.content{
	background-color: #fff;
	padding: 2.5vw 2vw;
	height: 100vh;
	overflow: hidden;
	overflow-y: auto;
	font-size: inherit;
	width: calc(100% - 4vw);
}
.content img {
	max-width: 100%;
}
.content image {
	max-width: 100%;
}
.title{
	padding: .5vw 0;
	font-size: 24px;
}
.time{
	padding: .5vw 0;
	color: #d0d0d0;
	font-size: 16px;
}
</style>

<style>
/* .uni-input input {
  height: 40px !important;
} */
.init_p{
	font-size: inherit;
	margin-block-start: 0em;
	margin-block-end: 0em;
	margin-inline-start: 0px;
	margin-inline-end: 0px;
}
</style>
